home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / rt.jar / javax / smartcardio / ResponseAPDU.class (.txt) < prev    next >
Encoding:
Java Class File  |  2006-11-29  |  1.7 KB  |  74 lines

  1. package javax.smartcardio;
  2.  
  3. import java.io.IOException;
  4. import java.io.ObjectInputStream;
  5. import java.io.Serializable;
  6. import java.util.Arrays;
  7.  
  8. public final class ResponseAPDU implements Serializable {
  9.    private static final long serialVersionUID = 6962744978375594225L;
  10.    private byte[] apdu;
  11.  
  12.    public ResponseAPDU(byte[] var1) {
  13.       var1 = (byte[])(([B)var1).clone();
  14.       check(var1);
  15.       this.apdu = var1;
  16.    }
  17.  
  18.    private static void check(byte[] var0) {
  19.       if (var0.length < 2) {
  20.          throw new IllegalArgumentException("apdu must be at least 2 bytes long");
  21.       }
  22.    }
  23.  
  24.    public int getNr() {
  25.       return this.apdu.length - 2;
  26.    }
  27.  
  28.    public byte[] getData() {
  29.       byte[] var1 = new byte[this.apdu.length - 2];
  30.       System.arraycopy(this.apdu, 0, var1, 0, var1.length);
  31.       return var1;
  32.    }
  33.  
  34.    public int getSW1() {
  35.       return this.apdu[this.apdu.length - 2] & 255;
  36.    }
  37.  
  38.    public int getSW2() {
  39.       return this.apdu[this.apdu.length - 1] & 255;
  40.    }
  41.  
  42.    public int getSW() {
  43.       return this.getSW1() << 8 | this.getSW2();
  44.    }
  45.  
  46.    public byte[] getBytes() {
  47.       return (byte[])this.apdu.clone();
  48.    }
  49.  
  50.    public String toString() {
  51.       return "ResponseAPDU: " + this.apdu.length + " bytes, SW=" + Integer.toHexString(this.getSW());
  52.    }
  53.  
  54.    public boolean equals(Object var1) {
  55.       if (this == var1) {
  56.          return true;
  57.       } else if (!(var1 instanceof ResponseAPDU)) {
  58.          return false;
  59.       } else {
  60.          ResponseAPDU var2 = (ResponseAPDU)var1;
  61.          return Arrays.equals(this.apdu, var2.apdu);
  62.       }
  63.    }
  64.  
  65.    public int hashCode() {
  66.       return Arrays.hashCode(this.apdu);
  67.    }
  68.  
  69.    private void readObject(ObjectInputStream var1) throws IOException, ClassNotFoundException {
  70.       this.apdu = (byte[])var1.readUnshared();
  71.       check(this.apdu);
  72.    }
  73. }
  74.